﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;

namespace Com.CMS263.Web.manage.ManageArtType
{
    public partial class action : System.Web.UI.Page
    {
        ArtTypeBLL bll = new ArtTypeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = int.Parse(Request["id"]);


            DeleteDelete(id);
            string menu = bll.GetTypeTree();
            FileUtil.WriteToFile(Server.MapPath("/manage/menutext/menu.txt"), menu);
            
            Response.Write("ok");
        }

        public void DeleteDelete(int id)
        {
            IList<ArtType> sublist = bll.GetArtTypeByPid(id);
            bll.DeleteTypeById(id);
            if (sublist.Count > 0)
            {
                foreach (ArtType at in sublist)
                {
                    DeleteDelete(at.id);
                }
            }

        }
    }
}
